package com.ruoyi.web.controller.yijing;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yijing.domain.YjCategory;
import com.ruoyi.yijing.service.IYjCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 占卜问题分类Controller
 * 
 * @author ruoyi
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/yijing/category")
public class YjCategoryController extends BaseController
{
    @Autowired
    private IYjCategoryService yjCategoryService;

    /**
     * 查询占卜问题分类列表
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjCategory yjCategory)
    {
        startPage();
        List<YjCategory> list = yjCategoryService.selectYjCategoryList(yjCategory);
        return getDataTable(list);
    }


    /**
     * 获取占卜问题分类详细信息
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yjCategoryService.selectYjCategoryById(id));
    }

    /**
     * 新增占卜问题分类
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:add')")
    @Log(title = "添加占卜问题分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjCategory yjCategory)
    {
        return toAjax(yjCategoryService.insertYjCategory(yjCategory));
    }

    /**
     * 修改占卜问题分类
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:edit')")
    @Log(title = "修改占卜问题分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjCategory yjCategory)
    {
        return toAjax(yjCategoryService.updateYjCategory(yjCategory));
    }

    @Log(title = "修改占卜问题分类状态", businessType = BusinessType.UPDATE)
    @PutMapping("updateStatus")
    public AjaxResult updateStatus(@RequestBody YjCategory yjCategory)
    {
        return toAjax(yjCategoryService.updateYjCategory(yjCategory));
    }


    /**
     * 删除占卜问题分类
     */
    //@PreAuthorize("@ss.hasPermi('yijing:category:remove')")
    @Log(title = "占卜问题分类", businessType = BusinessType.DELETE)
	//@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yjCategoryService.deleteYjCategoryByIds(ids));
    }
}
